Repository navigation
Promote dev to stable: socket transport diagnostics - #2478
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughParses runtime socketDir/port from ChangesMetadata version bumps
Pgserve transport, health reporting, and brain CLI handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the project version to 4.260522.16 and enhances pgserve diagnostic reporting by adding support for Unix socket transport detection. Key changes include the introduction of extractPgserveSocketDirFromStatus, updates to extractPgservePortFromStatus for better runtime status parsing, and a refactor of the health check logic in serve.ts to use a unified transport resolver. Review feedback suggests refining the transport detection logic to handle the '0' port sentinel and incrementing the diagnostic schema version to reflect the additive changes to the report structure.
| const pgserveStatusJson = (await runCommandSilent('pgserve', ['status', '--json'], undefined, 2000)).output.trim(); | ||
| const pgserveSocketDir = extractPgserveSocketDirFromStatus(pgserveStatusJson); | ||
| const pgservePort = pgservePortFromFile ?? extractPgservePortFromStatus(pgserveStatusJson); | ||
| const pgserveTransport = pgserveSocketDir ? 'unix-socket' : pgservePort ? 'tcp' : null; |
There was a problem hiding this comment.
The transport detection logic should account for the SOCKET_PORT_SENTINEL (value "0"), which indicates a Unix socket transport even if the socketDir wasn't explicitly extracted from the status JSON. Additionally, since pgservePort might contain trailing whitespace if read from the legacy port file, it's safer to trim it during the check.
| const pgserveTransport = pgserveSocketDir ? 'unix-socket' : pgservePort ? 'tcp' : null; | |
| const pgserveTransport = pgserveSocketDir || pgservePort?.trim() === '0' ? 'unix-socket' : pgservePort?.trim() ? 'tcp' : null; |
References
- It is acceptable to use hardcoded numeric limits or sentinel values in non-critical fallback logic to prevent performance issues or handle specific states.
| pgserveTransport, | ||
| pgserveSocketDir, |
There was a problem hiding this comment.
This change introduces new fields (pgserveTransport, pgserveSocketDir) to the diagnostics report. According to the internal guidelines, UPDATE_DIAGNOSTIC_SCHEMA_VERSION should be incremented for any additive change to the schema to allow consumers to correctly identify the available metadata.
References
- Increment schema versioning for additive changes to diagnostic reports. (link)
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Line 3: The release bump updated "version" without updating the pinned binary
hashes, causing SHA drift; update the "binarySha256" entries in package.json to
match the current release assets (or revert the asset set to match existing
pins) so CI integrity checks pass—locate the binarySha256 fields in
package.json, fetch the correct SHA256 for each referenced release asset, and
replace the stale values with the new hashes before merging.
In `@src/genie-commands/__tests__/update.test.ts`:
- Around line 909-918: Add a test asserting that when both top-level port and
runtime.port are present but different, runtime.port takes precedence: create a
JSON string with installed: true, status: 'online', port: '1234' (or number),
and runtime: { port: 8432, live: true } and call extractPgservePortFromStatus to
expect '8432'. Place this new case alongside the existing diagnostics tests
(same suite that contains the current live-status test) so the behavior of
extractPgservePortFromStatus is verified for the conflict-case.
In `@src/genie-commands/update.ts`:
- Around line 1269-1271: The port-selection logic currently uses parsed.port /
parsed.instance?.port before live data, causing stale values to be chosen;
update the fallback order so parsed.runtime?.port is preferred over legacy
fields by computing rawPort from parsed.runtime?.port ?? parsed.port ??
parsed.instance?.port (keep the same type checks that follow: allow finite
number -> String(...) and non-empty trimmed string), and ensure you reference
the same variable name rawPort so subsequent checks (Number.isFinite and trim)
still apply.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 41ead3fc-5184-4766-af73-49a1d430624b
📒 Files selected for processing (7)
.claude-plugin/marketplace.jsonpackage.jsonplugins/genie/.claude-plugin/plugin.jsonplugins/genie/package.jsonsrc/genie-commands/__tests__/update.test.tssrc/genie-commands/update.tssrc/term-commands/serve.ts
| { | ||
| "name": "@automagik/genie", | ||
| "version": "4.260522.14", | ||
| "version": "4.260522.16", |
There was a problem hiding this comment.
Update binarySha256 pins before merge.
CI is failing with SHA drift, which means the pinned hashes in package.json no longer match downloaded release assets. This release/version bump should include refreshed binarySha256 entries (or the asset set must be reverted to match current pins), otherwise release integrity checks stay red.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@package.json` at line 3, The release bump updated "version" without updating
the pinned binary hashes, causing SHA drift; update the "binarySha256" entries
in package.json to match the current release assets (or revert the asset set to
match existing pins) so CI integrity checks pass—locate the binarySha256 fields
in package.json, fetch the correct SHA256 for each referenced release asset, and
replace the stale values with the new hashes before merging.
| test('diagnostics derives pgserve port from live pgserve runtime status json', () => { | ||
| const liveStatus = JSON.stringify({ | ||
| installed: true, | ||
| status: 'online', | ||
| port: null, | ||
| runtime: { port: 8432, live: true }, | ||
| }); | ||
|
|
||
| expect(extractPgservePortFromStatus(liveStatus)).toBe('8432'); | ||
| }); |
There was a problem hiding this comment.
Add a conflict-case test for runtime.port precedence.
Current coverage only checks runtime fallback when top-level port is null. Add a case where both are present but different, and assert runtime wins.
Suggested test addition
+ test('diagnostics prefers runtime.port over stale top-level port when both are present', () => {
+ const liveStatus = JSON.stringify({
+ port: 15432,
+ runtime: { port: 8432, live: true },
+ });
+ expect(extractPgservePortFromStatus(liveStatus)).toBe('8432');
+ });As per coding guidelines: "Test edge cases and boundaries of every command, flag, and plugin contract".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test('diagnostics derives pgserve port from live pgserve runtime status json', () => { | |
| const liveStatus = JSON.stringify({ | |
| installed: true, | |
| status: 'online', | |
| port: null, | |
| runtime: { port: 8432, live: true }, | |
| }); | |
| expect(extractPgservePortFromStatus(liveStatus)).toBe('8432'); | |
| }); | |
| test('diagnostics derives pgserve port from live pgserve runtime status json', () => { | |
| const liveStatus = JSON.stringify({ | |
| installed: true, | |
| status: 'online', | |
| port: null, | |
| runtime: { port: 8432, live: true }, | |
| }); | |
| expect(extractPgservePortFromStatus(liveStatus)).toBe('8432'); | |
| }); | |
| test('diagnostics prefers runtime.port over stale top-level port when both are present', () => { | |
| const liveStatus = JSON.stringify({ | |
| port: 15432, | |
| runtime: { port: 8432, live: true }, | |
| }); | |
| expect(extractPgservePortFromStatus(liveStatus)).toBe('8432'); | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/genie-commands/__tests__/update.test.ts` around lines 909 - 918, Add a
test asserting that when both top-level port and runtime.port are present but
different, runtime.port takes precedence: create a JSON string with installed:
true, status: 'online', port: '1234' (or number), and runtime: { port: 8432,
live: true } and call extractPgservePortFromStatus to expect '8432'. Place this
new case alongside the existing diagnostics tests (same suite that contains the
current live-status test) so the behavior of extractPgservePortFromStatus is
verified for the conflict-case.
| const rawPort = parsed.port ?? parsed.instance?.port ?? parsed.runtime?.port; | ||
| if (typeof rawPort === 'number' && Number.isFinite(rawPort)) return String(rawPort); | ||
| if (typeof rawPort === 'string' && rawPort.trim()) return rawPort.trim(); |
There was a problem hiding this comment.
Prefer runtime.port over legacy status fields for live diagnostics.
Line 1269 currently prioritizes port/instance.port before runtime.port, which can report stale metadata even when live runtime data exists. This conflicts with the live-runtime diagnostics intent.
Suggested fix
- const rawPort = parsed.port ?? parsed.instance?.port ?? parsed.runtime?.port;
+ const rawPort = parsed.runtime?.port ?? parsed.port ?? parsed.instance?.port;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const rawPort = parsed.port ?? parsed.instance?.port ?? parsed.runtime?.port; | |
| if (typeof rawPort === 'number' && Number.isFinite(rawPort)) return String(rawPort); | |
| if (typeof rawPort === 'string' && rawPort.trim()) return rawPort.trim(); | |
| const rawPort = parsed.runtime?.port ?? parsed.port ?? parsed.instance?.port; | |
| if (typeof rawPort === 'number' && Number.isFinite(rawPort)) return String(rawPort); | |
| if (typeof rawPort === 'string' && rawPort.trim()) return rawPort.trim(); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/genie-commands/update.ts` around lines 1269 - 1271, The port-selection
logic currently uses parsed.port / parsed.instance?.port before live data,
causing stale values to be chosen; update the fallback order so
parsed.runtime?.port is preferred over legacy fields by computing rawPort from
parsed.runtime?.port ?? parsed.port ?? parsed.instance?.port (keep the same type
checks that follow: allow finite number -> String(...) and non-empty trimmed
string), and ensure you reference the same variable name rawPort so subsequent
checks (Number.isFinite and trim) still apply.
Summary\n- report pgserve Unix socket transport in update diagnostics\n- include pgserve socketDir while keeping port only as legacy metadata\n- make serve status use resolvePgserveTransport() instead of stale active-port state\n- includes prior pgserve runtime.port diagnostics fix\n\n## Verification\n- GENIE_TEST_SKIP_PGSERVE=1 bun test src/genie-commands/tests/update.test.ts\n- bun run typecheck\n- bun run lint\n- bun run dead-code\n- bun run skills:lint\n- bun run wishes:lint\n- bun run lint:emit
Summary by CodeRabbit
New Features
Chores